<template>
  <div class="child">
    <h2>子组件Child----->{{msg}}</h2>
    <GrandSon></GrandSon>
  </div>
</template>

<script>
import {inject,toRefs} from 'vue'
import GrandSon from "./GrandSon.vue";
export default {
  components: {
    GrandSon,
  },
  setup(){
    const state=inject('msg')
    return {
        ...toRefs(state)
    }
  }
};
</script>

<style>
.child {
  padding: 20px;
  background-color: springgreen;
}
</style>